package com.itheima.tanhua.mongo;

import com.itheima.tanhua.enums.CommentType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "video")
public class Video implements java.io.Serializable {

    private static final long serialVersionUID = -3136732836884933873L;

    private ObjectId id; //主键id
    private Long vid; //自动增长
    private Long created; //创建时间


    private Long userId;
    private String text; //文字
    private String picUrl; //视频封面文件，URL
    private String videoUrl; //视频文件，URL


    private Integer likeCount = 0; //点赞数
    private Integer commentCount = 0; //评论数
    private Integer loveCount = 0; //喜欢数

    public Integer staticCount(Integer type) {
        if (type == CommentType.VIDEO_COMMENT.getType()) {
            return this.getCommentCount();
        } else if (type == CommentType.VIDEO_LIKE.getType()) {
            return this.getLikeCount();
        } else if (type == CommentType.VIDEO_LOVE.getType()) {
            return this.getLoveCount();
        }
        return -1;
    }
}